package com.mango.data.structure.hash;

import java.util.Date;

/**
 * @Author: mango
 * @Date: 2022/5/21 11:28 上午
 */
public class HMTest {
    public static void main(String[] args) {
        HashMap<String,Object> map = new HashMap<>();
        map.put("aa","bb");
        System.out.println(map.get("aa"));
        System.out.println(map.toString());
        map.put("aa1",new Date());
        map.put("aa3",new Date());
        System.out.println(map.get("aa1"));
        System.out.println(map.toString());
        for(int i = 0;i<10;i++){
            map.put("i"+i,Math.random());
        }
        System.out.println(map.toString());
        System.out.println(map.get("i9"));
        map.remove("aa1");
        System.out.println(map.toString());
        System.out.println(map.get("i9"));

        System.out.println(map.get("aa"));
        map.put("aa","中国");
        System.out.println(map.get("aa"));

        System.out.println(map.keySet());
        System.out.println(map.entrySet());

        for(String key : map.keySet()){
            System.out.println("key="+key+",value="+map.get(key));
        }

        for(int i = 0;i<10;i++){
            map.remove("i"+i);
            System.out.println(map);
        }

        map.clear();
        System.out.println(map.toString());


    }
}
